package cn.gson.springboot.model.service.afterservice;

import cn.gson.springboot.model.dao.afterdao.CustomerCareDao;
import cn.gson.springboot.model.mapper.aftermapper.CustomerCareMapper;
import cn.gson.springboot.model.pjos.CustomerCare;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CustomerCareService {

    @Autowired
    CustomerCareDao dao;
    @Autowired
    CustomerCareMapper mapper;

    //客户关怀分页查询
    public List<CustomerCare> selectCurePage(String types, String search){
        return mapper.carePage(types,search);
    }

    //新建客户关怀表
    public void addCare(CustomerCare care){
        care.setCareDelete(1);
        dao.save(care);
    }

    //数据回显
    public CustomerCare selectByCareId(Integer careId){
        return mapper.careByCareId(careId);
    }

    //逻辑删除
    public void deleteCareId(Integer careId){
        if(careId != null){
            CustomerCare care = dao.findById(careId).get();
            care.setCareDelete(0);
            dao.save(care);
        }
    }
}
